package com.itheima.stock.controller;

import com.itheima.stock.common.domain.InnerMarketDomain;
import com.itheima.stock.common.domain.StockUpdownDomain;
import com.itheima.stock.pojo.StockBusiness;
import com.itheima.stock.pojo.StockRtInfo;
import com.itheima.stock.service.StockService;
import com.itheima.stock.vo.resp.PageResult;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/quot")
public class StockController {

    @Autowired
    private StockService stockService;

    @GetMapping("/stock/business/all")
    public List<StockBusiness> findAllBusinessInfo(){
        return stockService.findAll();
    }

    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getNewAMarketInfo(){
        return stockService.getNewAMarketInfo();
    }

    @GetMapping("/stock/increase")
    public R<List<StockUpdownDomain>> getStockRtInfoLimit(){
        return stockService.getStockInfoLimit();
    }

    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockInfo4Page(Integer page , Integer pageSize){
        return stockService.getStockInfo4Page(page,pageSize);
    }

    @GetMapping("/stock/updown/count")
    public R<Map> getStockUpdownCount(){
        return stockService.getStockUpdownCount();
    }

    @GetMapping("/stock/export")
    public void stockExport(HttpServletResponse response,Integer page,Integer pageSize) throws IOException {
        stockService.stockExport(response,page,pageSize);
    }
}
